package com.hmkj.core.mapper.userAuth;

import com.hmkj.common.baseMapper.GenericMapper;
import com.hmkj.core.model.userAuth.UserAuthModel;
import com.hmkj.core.po.userAuth.UserAuth;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 用户实名认证记录相关Dao接口<br>
 *
 * @author lizhijie
 * @date   2018-07-04 04:34:26
 */
public interface UserAuthMapper extends GenericMapper< UserAuth,Integer> {

    @Select("SELECT t.*,a.* FROM biz_user_auth t LEFT JOIN biz_user_identify a ON t.user_id = a.user_id WHERE 1=1 ${whereSql} ${sortSql} limit ${nowPage}, ${pageSize} ")
    List<UserAuthModel> findListBySqlJoin(Map<String, Object> params);

    @Select("SELECT count(1) FROM biz_user_auth t LEFT JOIN biz_user_identify a ON t.user_id = a.user_id WHERE 1=1 ${whereSql}")
    long countBySqlJoin(Map<String, Object> params);

    /**
     * 根据用户ID 查询用户开户信息
     *
     * @param userId 用户ID
     * @return
     */
    @Select("SELECT * FROM biz_user_auth WHERE user_id = #{userId} and del_flag = 1")
    UserAuth selectByUID(@Param(value = "userId") int userId);
}
